@extends('admin.layouts.app')
@section('content')

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">平台管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="#">系统</a></li>
                                    <li><a href="{{url('zadmin/materials')}}">素材管理</a></li>
                                    <li class="active">添加素材</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                            <h2 class="m-t-0 header-title">添加素材</h2>
                            <hr/>
                             
                              @include('admin.common.error')
                        			<div class="row">
			                        	<div class="col-md-10">
                                  <form class="form-horizontal" role="form" action="{{url('zadmin/materials')}}" method="post">

                                <div class="form-group">
                                    <label class="col-md-2 control-label">商品</label>
                                  <div class="col-md-10">
                                    <select class="form-control" name="product_id" required="" >
                                      @foreach($products as $product)
                                      <option value="{{$product->id}}">{{$product->name}}</option>
                                      @endforeach
                                    </select>
                                  </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label">文字</label>
                                  <div class="col-md-10">
                                    <textarea class="form-control" name="msg" required="" ></textarea>
                                  </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-2 control-label">图片</label>
                                  <div class="col-md-10">
                                     <div id="filelist"></div>

                  <div class="piclist"></div>
                                    <button class="btn" type="button" id="pickfiles">选择图片</button>
                                   
                                   
                                  </div>
                                </div>
                                              

                                              

                                              <div class="form-group text-center">
                                                  
                                                  <button type="submit" class="btn btn-info waves-effect waves-light">保存</button>
                                              </div>
                                              
                                               <input  id="pics" name="pics" type="hidden">
                             {{csrf_field()}}
                                          </form>
                                </div>
			                        	
			                        </div>

                             
			                        
                        			
                        		</div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
                        
                        

                  
            
         
       

           



    
        @section('js')

         <script type="text/javascript" src="/js/plupload.full.min.js"></script>
 

        <script type="text/javascript">
          var pics = '';
          var uploader = new plupload.Uploader({
              runtimes : 'html5,flash,silverlight,html4',
              browse_button : 'pickfiles',               
              url : '/upload.php',
              flash_swf_url : '../js/Moxie.swf',
              silverlight_xap_url : '../js/Moxie.xap',
              
              filters : {
                max_file_size : '10mb',
                mime_types: [
                  {title : "Image files", extensions : "jpg,gif,png"},
                  {title : "Zip files", extensions : "zip"}
                ]
              },

              init: {
                PostInit: function() {
                  $('#filelist').html('');

                  
                },

                FilesAdded: function(up, files) {
                  plupload.each(files, function(file) {
                    $('#filelist').html('<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>');
                     uploader.start();
                     return false;
                  });
                },

                

                 FileUploaded: function(up, file, info) {
                    // Called when file has finished uploading
                    var rs =  JSON.parse(info.response);
                    if(rs.status){
                      var str = '<img  src="'+rs.data+'" class="img-rounded img-responsive img-thumbnail" width="100">';
                      $('.piclist').append(str);
                      pics += rs.data+',';
                      $('#pics').val(pics);
                    }
                    console.info(rs);                              
                },
              }
          });
      uploader.init();


   
        </script>
        @endsection
    
